import java.awt.Color ;

public class Curve {
	public final OrderedPair [] pts ;
	public Object id ;
	public boolean isVisible = false ;
	public final double xmin , xmax , ymin , ymax ;
	private Color c = Color.BLACK ;
	
	public Color getColor ( ) {
		return c ;
	}
	
	public void setColor ( Color c ) {
		this.c = c ;
	}
	
	public Curve copy ( ) {
		Curve result = new Curve ( pts , id ) ;
		result.isVisible = isVisible ;
		result.c = c ;
		return result ;
	}
	
	public Curve ( OrderedPair [] pts , Object id ) {
		double xmin = Double.POSITIVE_INFINITY ;
		double ymin = xmin ;
		double xmax = Double.NEGATIVE_INFINITY ;
		double ymax = xmax ;
		int i ;
		this.pts = pts ;
		for ( i = 0 ; i < pts.length ; i ++ ) {
			if ( pts[i].x > xmax ) xmax = pts[i].x ;
			if ( pts[i].x < xmin ) xmin = pts[i].x ;
			if ( pts[i].y > ymax ) ymax = pts[i].y ;
			if ( pts[i].y < ymin ) ymin = pts[i].y ;
		}
		this.xmax = xmax ;
		this.xmin = xmin ;
		this.ymax = ymax ;
		this.ymin = ymin ;
		this.id = id ;
	}
	
	public Curve ( double [ ] x , double [ ] y , Object id ) throws Exception {
		OrderedPair [ ] curve ;
		int i ;
		double xmin = Double.POSITIVE_INFINITY ;
		double ymin = xmin ;
		double xmax = Double.NEGATIVE_INFINITY ;
		double ymax = xmax ;
		
		if ( x == null || y == null ) throw new Exception ( ) ;
		if ( x.length != y.length ) throw new Exception ( ) ;

		curve = new OrderedPair [ x.length ] ;
		
		for ( i = 0 ; i < x.length ; i ++ ) {
			curve [ i ] = new OrderedPair ( x [ i ] , y [ i ] ) ;
			if ( x [ i ] > xmax ) xmax = x [ i ] ;
			if ( x [ i ] < xmin ) xmin = x [ i ] ;
			if ( y [ i ] > ymax ) ymax = y [ i ] ;
			if ( y [ i ] < ymin ) ymin = y [ i ] ;
		}
		pts = curve ;
		this.id = id ;
		this.xmax = xmax ;
		this.xmin = xmin ;
		this.ymax = ymax ;
		this.ymin = ymin ;
	}
}
